#include "../../libraries/sockets/udp_socket.h"

#include <iostream>

using namespace std;

int main(int argc, char *argv[])

{
    if (argc<3){
        cout <<"use this format: ./server IP portno" <<endl;
        exit(1);
    }

    UDP_socket clientUDP;

    string message, response;

    clientUDP.connect(argv[1]);

    if (clientUDP.getServer()==0) clientUDP.error("Unknown host");

    clientUDP.setPortno(atoi(argv[2]));


    while(1) //Comunicacion continuada
    {
        cout << "U write: " << endl;
        cin >> message;

        clientUDP<<message;

        cout << "Server says: " << endl;
        clientUDP>>response;

        cout << response << endl;
    }

    return 0;
}
